Skip to content

feat(index): per-vault SQLite FTS5 index + scan + reindex (M2a)#215

Merged
vreshch merged 1 commit into
masterfrom
feature/m2-offline-crud-index
Jul 6, 2026
Merged

feat(index): per-vault SQLite FTS5 index + scan + reindex (M2a)#215
vreshch merged 1 commit into
masterfrom
feature/m2-offline-crud-index

Conversation

@vreshch

@vreshch vreshch commented Jul 6, 2026

Copy link
Copy Markdown
Member

First slice of M2 - Offline CRUD + index. The index engine + vault reindex, ported to node:sqlite from the tested v0.24 module. No memory-core dependency (V3 = harvest), so this is not gated on the PR-0 relicense.

What

  • vault-index.ts - per-vault SQLite FTS5 index (~/.agentage/index/<name>.db): files + files_fts (bm25-ranked, porter/unicode61) + meta. search / stat / list / reconcile / fileCount / indexedAt. Lazy-loads node:sqlite so non-index commands never touch it.
  • vault-scan.ts - walk the markdown tree, diff by mtime/size then sha256, reconcile added/modified/removed. reindexVault(vaultPath, dbPath).
  • vault reindex [name] - rebuild one vault's index (or all) from its markdown.
  • cli.ts bootstrap - node:sqlite is behind --experimental-sqlite on Node < 23.4, so index commands re-exec once with the flag when it can't load; also silences the SQLite ExperimentalWarning. Non-index commands are untouched.
  • vitest - poolOptions.forks.execArgv passes the flag to test workers.

Design fit

Per [[daemon-index-ownership]] (V10): the CLI will reach the index through a MemoryClient whose default is the daemon (auto-started, harvested from v0.24) and whose fallback is direct in-process. This PR is the shared engine + the direct path - the daemon (M2.5) reuses vault-index.ts verbatim, so nothing here gets reworked. reindex runs direct today; it routes via the daemon once that lands.

Verify

  • npm run verify green: type-check (src + e2e), eslint, prettier, 127 unit tests, build. Coverage 88 / 86 / 77 / 89.
  • Ran the built binary: vault add a local vault of .md -> vault reindex reports +2, a second run is idempotent (=2), db lands at index/<name>.db, vault reindex (no name) does all. Warning is silenced.
  • Unit tests cover: FTS build/search/stat/list, modified/removed reconcile, empty-query, punctuation-as-literal, indexedAt; scan build + drop-db-and-reindex = identical results (index is a pure cache) + modified/removed/unchanged detection + dot-dir skip; reindex command routing (all / named / unknown / empty).

Next (M2b): the 6 memory verbs behind MemoryClient + DirectClient. Then M2.5 harvests the daemon.

- vault-index.ts: node:sqlite FTS5 index (files + files_fts + meta), ported from
  the archived v0.24 module; search/stat/list/reconcile, bm25-ranked, lazy-loaded
- vault-scan.ts: walk markdown + mtime/size/sha diff -> reconcile; reindexVault()
- vault reindex [name]: rebuild one or all vault indexes from markdown
- cli.ts: re-exec bootstrap with --experimental-sqlite for index commands on
  Node < 23.4, and silence the node:sqlite ExperimentalWarning
- vitest execArgv passes the flag to fork workers
- Direct in-process access = the DirectClient path per the daemon-index-ownership
  design (V10); the daemon will reuse this same engine
- 127 tests green, coverage 88/86/77/89; verified the built binary reindexes a
  real vault + is idempotent
@github-actions

github-actions Bot commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

🎉 PR Validation ✅ PASSED

Commit: f4704a06f8a2a1bd0c080c5884310d7920f494ef
Branch: feature/m2-offline-crud-index

Checks:

  • ✅ Release guard (no version/changelog changes)
  • ✅ Dependencies installed
  • ✅ Type check passed
  • ✅ Linting passed
  • ✅ Format check passed
  • ✅ Tests + coverage passed
  • ✅ Build successful

Ready to merge!


🔗 View workflow run
⏰ Generated at: 2026-07-06T00:04:55.778Z

@vreshch vreshch marked this pull request as ready for review July 6, 2026 00:05
@vreshch vreshch merged commit 7226639 into master Jul 6, 2026
2 checks passed
@vreshch vreshch deleted the feature/m2-offline-crud-index branch July 6, 2026 00:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant